﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Core;

namespace SM2SetupSearch
{
    public class QueryBuilderActions
    {
        public static void QueryBuilder_SetTextInto_builder_all_these_words_box(string strInput)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlDiv tabs_query_builder = create_search_form.Find.ById<HtmlDiv>("tabs-query-builder");
            HtmlDiv search_query_builder = tabs_query_builder.Find.ById<HtmlDiv>("search-query-builder");
            HtmlDiv wordChoices = search_query_builder.Find.ById<HtmlDiv>("wordChoices");


            HtmlInputText builder_all_these_words_box = wordChoices.Find.ById<HtmlInputText>("builder-all-these-words-box");
            SM2Input.Tradition.TypeTextIntoTextField(builder_all_these_words_box, strInput);
            builder_all_these_words_box.MouseClick(ArtOfTest.WebAii.Core.MouseClickType.LeftClick);
            System.Threading.Thread.Sleep(1000);
            Desktop desktop = new Desktop();
            desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
            System.Threading.Thread.Sleep(1000);
        }

        public static void QueryBuilder_SetTextInto_builder_this_exact_phrase_box(string strInput)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlDiv tabs_query_builder = create_search_form.Find.ById<HtmlDiv>("tabs-query-builder");
            HtmlDiv search_query_builder = tabs_query_builder.Find.ById<HtmlDiv>("search-query-builder");
            HtmlDiv wordChoices = search_query_builder.Find.ById<HtmlDiv>("wordChoices");


            HtmlInputText builder_this_exact_phrase_box = wordChoices.Find.ById<HtmlInputText>("builder-this-exact-phrase-box");
            SM2Input.Tradition.TypeTextIntoTextFieldWithHint(builder_this_exact_phrase_box, strInput);
            builder_this_exact_phrase_box.MouseClick(ArtOfTest.WebAii.Core.MouseClickType.LeftClick);
            System.Threading.Thread.Sleep(1000);
            Desktop desktop = new Desktop();
            desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
            System.Threading.Thread.Sleep(1000);
        }

        public static void QueryBuilder_SetTextInto_builder_or_phrase_box(string strInput)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlDiv tabs_query_builder = create_search_form.Find.ById<HtmlDiv>("tabs-query-builder");
            HtmlDiv search_query_builder = tabs_query_builder.Find.ById<HtmlDiv>("search-query-builder");
            HtmlDiv wordChoices = search_query_builder.Find.ById<HtmlDiv>("wordChoices");


            HtmlInputText builder_or_phrase_box = wordChoices.Find.ById<HtmlInputText>("builder-or-phrase-box");
            SM2Input.Tradition.TypeTextIntoTextFieldWithHint(builder_or_phrase_box, strInput);
            builder_or_phrase_box.MouseClick(ArtOfTest.WebAii.Core.MouseClickType.LeftClick);
            System.Threading.Thread.Sleep(1000);
            Desktop desktop = new Desktop();
            desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
            System.Threading.Thread.Sleep(1000);
        }

        public static void QueryBuilder_SetTextInto_builder_prefix_words_box(string strInput)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlDiv tabs_query_builder = create_search_form.Find.ById<HtmlDiv>("tabs-query-builder");
            HtmlDiv search_query_builder = tabs_query_builder.Find.ById<HtmlDiv>("search-query-builder");
            HtmlDiv wordChoices = search_query_builder.Find.ById<HtmlDiv>("wordChoices");


            HtmlInputText builder_prefix_words_box = wordChoices.Find.ById<HtmlInputText>("builder-prefix-words-box");
            SM2Input.Tradition.TypeTextIntoTextFieldWithHint(builder_prefix_words_box, strInput);
            builder_prefix_words_box.MouseClick(ArtOfTest.WebAii.Core.MouseClickType.LeftClick);
            System.Threading.Thread.Sleep(1000);
            Desktop desktop = new Desktop();
            desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
            System.Threading.Thread.Sleep(1000);
        }

        public static void QueryBuilder_SetTextInto_builder_proximity_words_box(string strInput)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlDiv tabs_query_builder = create_search_form.Find.ById<HtmlDiv>("tabs-query-builder");
            HtmlDiv search_query_builder = tabs_query_builder.Find.ById<HtmlDiv>("search-query-builder");
            HtmlDiv wordChoices = search_query_builder.Find.ById<HtmlDiv>("wordChoices");


            HtmlInputText builder_proximity_words_box = wordChoices.Find.ById<HtmlInputText>("builder-proximity-words-box");
            SM2Input.Tradition.TypeTextIntoTextFieldWithHint(builder_proximity_words_box, strInput);
            builder_proximity_words_box.MouseClick(ArtOfTest.WebAii.Core.MouseClickType.LeftClick); 
            System.Threading.Thread.Sleep(1000);
            Desktop desktop = new Desktop();
            desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
            System.Threading.Thread.Sleep(1000);
        }
    }
}
